{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6e3f44d7-4de8-49d1-b0ca-94502b023c09",
   "metadata": {},
   "outputs": [],
   "source": [
    "import yaml\n",
    "from types import SimpleNamespace\n",
    "\n",
    "with open(\"piezometric_database_ver2.yaml\", \"r\") as file:\n",
    "    database = yaml.safe_load(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8b7618c6-abe7-4c75-8ecf-ced4c30dfb86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2024.05.21'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "database['database_version']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "545d04dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'author': 'Marco A. Lopez-Sanchez',\n",
       " 'contact_email': 'marcoalopez (at) outlook.com',\n",
       " 'description': 'Piezometric database from GrainSizeTools script',\n",
       " 'created_at': datetime.date(2024, 5, 21),\n",
       " 'license': 'Open Database License (ODbL) - version 1.0',\n",
       " 'usage_terms': 'https://opendatacommons.org/licenses/odbl/summary/',\n",
       " 'contributors': None}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "database['metadata']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a64094a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'quartz': {'Stipp_Tullis': {'year': 2003,\n",
       "   'reference': 'https://doi.org/10.1029/2003GL018444',\n",
       "   'B': 669.0,\n",
       "   'm': 0.79,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "  'Stipp_Tullis_BLG': {'year': 2003,\n",
       "   'reference': 'https://doi.org/10.1029/2003GL018444',\n",
       "   'B': 1264.1,\n",
       "   'm': 1.64,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to recrystallization regime 1 (BLG)'},\n",
       "  'Holyoke': {'year': 2010,\n",
       "   'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001',\n",
       "   'B': 490.3,\n",
       "   'm': 0.79,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "  'Holyoke_BLG': {'year': 2010,\n",
       "   'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001',\n",
       "   'B': 883.9,\n",
       "   'm': 1.85,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "  'Cross': {'year': 2017,\n",
       "   'reference': 'https://doi.org/10.1002/2017GL073836',\n",
       "   'B': 593.0,\n",
       "   'm': 0.71,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'None'},\n",
       "  'Cross_HR': {'year': 2017,\n",
       "   'reference': 'https://doi.org/10.1002/2017GL073836',\n",
       "   'B': 450.9,\n",
       "   'm': 0.63,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'None'},\n",
       "  'Shimizu': {'year': 2008,\n",
       "   'reference': 'https://doi.org/10.1016/j.jsg.2008.03.004',\n",
       "   'B': 352.0,\n",
       "   'm': 0.8,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the median in log (base e) scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'The Shimizu (2008) piezometer requires entering the grain size as the\\nlogarithm of the median apparent grain size calculated using equivalent\\ncircular diameters with no stereological correction. It uses a different\\npiezometer model to the Twiss model in which the stress estimation is\\ntemperature-dependent.\\n'},\n",
       "  'Twiss': {'year': 1977,\n",
       "   'reference': 'https://www.doi.org/10.1007/BF01637105',\n",
       "   'B': 550.0,\n",
       "   'm': 0.68,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean grain size.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': 1.5,\n",
       "   'notes': 'Twiss (1977) piezometer was calibrated using the linear intercepts (LI) multiplied\\nby 1.5 (correction factor). Equivalent circular diameters (ECD) without stereological\\ncorrection must be converted to LIs using the empirical equation of De Hoff and\\nRhines (1968) as follows LI = (1.5 / sqrt(4/pi)) * ECD\\n'}},\n",
       " 'olivine': {'VanderWal_wet': {'year': 1993,\n",
       "   'reference': 'https://doi.org/10.1029/93GL01382',\n",
       "   'B': 1355.4,\n",
       "   'm': 0.75,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': True,\n",
       "   'correction_factor': 1.5,\n",
       "   'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'},\n",
       "  'Jung_Karato': {'year': 2001,\n",
       "   'reference': 'https://doi.org/10.1016/S0191-8141(01)00005-0',\n",
       "   'B': 5461.03,\n",
       "   'm': 0.85,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': True,\n",
       "   'correction_factor': 1.5,\n",
       "   'notes': 'The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}},\n",
       " 'calcite': {'Rutter_SGR': {'year': 1995,\n",
       "   'reference': 'https://doi.org/10.1029/95JB02500',\n",
       "   'B': 812.83,\n",
       "   'm': 0.88,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to subgrain rotation recrystallization'},\n",
       "  'Rutter_GBM': {'year': 1995,\n",
       "   'reference': 'https://doi.org/10.1029/95JB02500',\n",
       "   'B': 2691.53,\n",
       "   'm': 0.89,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Only applies to grain boundary migration recrystallization'},\n",
       "  'Barnhoorn': {'year': 2003,\n",
       "   'reference': 'https://doi.org/10.1016/j.jsg.2003.11.024',\n",
       "   'B': 537.03,\n",
       "   'm': 0.82,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'None'},\n",
       "  'Platt_Bresser': {'year': 2017,\n",
       "   'reference': 'https://doi.org/10.1016/j.jsg.2017.10.012',\n",
       "   'B': 538.4,\n",
       "   'm': 0.82,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS) in linear scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'Contrary to other calcite piezometers, this one was calibrated using the RMS mean\\ninstead of the arithmetic mean.\\n'},\n",
       "  'Valcke': {'year': 2015,\n",
       "   'reference': 'https://doi.org/10.1144/SP409.4',\n",
       "   'B': 1467.92,\n",
       "   'm': 1.67,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size the arithmetic mean in linear scale.',\n",
       "   'linear_intercepts': False,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'None'}},\n",
       " 'feldspar': {'Post_Tullis_BLG': {'year': 1999,\n",
       "   'reference': 'https://doi.org/10.1016/S0040-1951(98)00260-1',\n",
       "   'B': 433.4,\n",
       "   'm': 1.52,\n",
       "   'warn': 'Please ensure that you have entered the apparent grain size as the median in linear scale.',\n",
       "   'linear_intercepts': True,\n",
       "   'correction_factor': False,\n",
       "   'notes': 'The Post and Tullis (1999) piezometer was calibrated using the median of the\\nequivalent circular diameters (ECD) grain size with no stereological correction.\\n'}}}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "database[\"data\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4f0fb918-c6f1-43b2-b482-b659df96d7b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "quartz\n",
      "olivine\n",
      "calcite\n",
      "feldspar\n"
     ]
    }
   ],
   "source": [
    "for mineral, piezometers in database[\"data\"].items():\n",
    "        print(mineral)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ae8fbf1e-a826-4032-97dc-936ade719ce0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stipp_Tullis\n",
      "Stipp_Tullis_BLG\n",
      "Holyoke\n",
      "Holyoke_BLG\n",
      "Cross\n",
      "Cross_HR\n",
      "Shimizu\n",
      "Twiss\n",
      "VanderWal_wet\n",
      "Jung_Karato\n",
      "Rutter_SGR\n",
      "Rutter_GBM\n",
      "Barnhoorn\n",
      "Platt_Bresser\n",
      "Valcke\n",
      "Post_Tullis_BLG\n"
     ]
    }
   ],
   "source": [
    "for mineral, piezometers in database[\"data\"].items():\n",
    "    for name, attributes in piezometers.items():\n",
    "        print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "efe8d405-81d9-46d4-b17f-82393a58d3aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'year': 2003, 'reference': 'https://doi.org/10.1029/2003GL018444', 'B': 669.0, 'm': 0.79, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'}\n",
      "{'year': 2003, 'reference': 'https://doi.org/10.1029/2003GL018444', 'B': 1264.1, 'm': 1.64, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to recrystallization regime 1 (BLG)'}\n",
      "{'year': 2010, 'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001', 'B': 490.3, 'm': 0.79, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'}\n",
      "{'year': 2010, 'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001', 'B': 883.9, 'm': 1.85, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'}\n",
      "{'year': 2017, 'reference': 'https://doi.org/10.1002/2017GL073836', 'B': 593.0, 'm': 0.71, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'None'}\n",
      "{'year': 2017, 'reference': 'https://doi.org/10.1002/2017GL073836', 'B': 450.9, 'm': 0.63, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'None'}\n",
      "{'year': 2008, 'reference': 'https://doi.org/10.1016/j.jsg.2008.03.004', 'B': 352.0, 'm': 0.8, 'warn': 'Please ensure that you have entered the apparent grain size as the median in log (base e) scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'The Shimizu (2008) piezometer requires entering the grain size as the\\nlogarithm of the median apparent grain size calculated using equivalent\\ncircular diameters with no stereological correction. It uses a different\\npiezometer model to the Twiss model in which the stress estimation is\\ntemperature-dependent.\\n'}\n",
      "{'year': 1977, 'reference': 'https://www.doi.org/10.1007/BF01637105', 'B': 550.0, 'm': 0.68, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean grain size.', 'linear_intercepts': False, 'correction_factor': 1.5, 'notes': 'Twiss (1977) piezometer was calibrated using the linear intercepts (LI) multiplied\\nby 1.5 (correction factor). Equivalent circular diameters (ECD) without stereological\\ncorrection must be converted to LIs using the empirical equation of De Hoff and\\nRhines (1968) as follows LI = (1.5 / sqrt(4/pi)) * ECD\\n'}\n",
      "{'year': 1993, 'reference': 'https://doi.org/10.1029/93GL01382', 'B': 1355.4, 'm': 0.75, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.', 'linear_intercepts': True, 'correction_factor': 1.5, 'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}\n",
      "{'year': 2001, 'reference': 'https://doi.org/10.1016/S0191-8141(01)00005-0', 'B': 5461.03, 'm': 0.85, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.', 'linear_intercepts': True, 'correction_factor': 1.5, 'notes': 'The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}\n",
      "{'year': 1995, 'reference': 'https://doi.org/10.1029/95JB02500', 'B': 812.83, 'm': 0.88, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to subgrain rotation recrystallization'}\n",
      "{'year': 1995, 'reference': 'https://doi.org/10.1029/95JB02500', 'B': 2691.53, 'm': 0.89, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Only applies to grain boundary migration recrystallization'}\n",
      "{'year': 2003, 'reference': 'https://doi.org/10.1016/j.jsg.2003.11.024', 'B': 537.03, 'm': 0.82, 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'None'}\n",
      "{'year': 2017, 'reference': 'https://doi.org/10.1016/j.jsg.2017.10.012', 'B': 538.4, 'm': 0.82, 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS) in linear scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'Contrary to other calcite piezometers, this one was calibrated using the RMS mean\\ninstead of the arithmetic mean.\\n'}\n",
      "{'year': 2015, 'reference': 'https://doi.org/10.1144/SP409.4', 'B': 1467.92, 'm': 1.67, 'warn': 'Please ensure that you have entered the apparent grain size the arithmetic mean in linear scale.', 'linear_intercepts': False, 'correction_factor': False, 'notes': 'None'}\n",
      "{'year': 1999, 'reference': 'https://doi.org/10.1016/S0040-1951(98)00260-1', 'B': 433.4, 'm': 1.52, 'warn': 'Please ensure that you have entered the apparent grain size as the median in linear scale.', 'linear_intercepts': True, 'correction_factor': False, 'notes': 'The Post and Tullis (1999) piezometer was calibrated using the median of the\\nequivalent circular diameters (ECD) grain size with no stereological correction.\\n'}\n"
     ]
    }
   ],
   "source": [
    "for mineral, piezometers in database[\"data\"].items():\n",
    "    for name, attributes in piezometers.items():\n",
    "        print(attributes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d98587ca-951c-4d7a-90ce-c6c6da4136b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_database = SimpleNamespace(**database[\"data\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9605c6ee-10e4-4fcc-a23f-7ac56c801065",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "types.SimpleNamespace"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(new_database)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7431c85f-832d-4f5f-8132-a04b95ac72d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "namespace(quartz={'Stipp_Tullis': {'year': 2003,\n",
       "                   'reference': 'https://doi.org/10.1029/2003GL018444',\n",
       "                   'B': 669.0,\n",
       "                   'm': 0.79,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "                  'Stipp_Tullis_BLG': {'year': 2003,\n",
       "                   'reference': 'https://doi.org/10.1029/2003GL018444',\n",
       "                   'B': 1264.1,\n",
       "                   'm': 1.64,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'Only applies to recrystallization regime 1 (BLG)'},\n",
       "                  'Holyoke': {'year': 2010,\n",
       "                   'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001',\n",
       "                   'B': 490.3,\n",
       "                   'm': 0.79,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "                  'Holyoke_BLG': {'year': 2010,\n",
       "                   'reference': 'https://doi.org/10.1016/j.tecto.2010.08.001',\n",
       "                   'B': 883.9,\n",
       "                   'm': 1.85,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'},\n",
       "                  'Cross': {'year': 2017,\n",
       "                   'reference': 'https://doi.org/10.1002/2017GL073836',\n",
       "                   'B': 593.0,\n",
       "                   'm': 0.71,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'None'},\n",
       "                  'Cross_HR': {'year': 2017,\n",
       "                   'reference': 'https://doi.org/10.1002/2017GL073836',\n",
       "                   'B': 450.9,\n",
       "                   'm': 0.63,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'None'},\n",
       "                  'Shimizu': {'year': 2008,\n",
       "                   'reference': 'https://doi.org/10.1016/j.jsg.2008.03.004',\n",
       "                   'B': 352.0,\n",
       "                   'm': 0.8,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the median in log (base e) scale.',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': False,\n",
       "                   'notes': 'The Shimizu (2008) piezometer requires entering the grain size as the\\nlogarithm of the median apparent grain size calculated using equivalent\\ncircular diameters with no stereological correction. It uses a different\\npiezometer model to the Twiss model in which the stress estimation is\\ntemperature-dependent.\\n'},\n",
       "                  'Twiss': {'year': 1977,\n",
       "                   'reference': 'https://www.doi.org/10.1007/BF01637105',\n",
       "                   'B': 550.0,\n",
       "                   'm': 0.68,\n",
       "                   'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean grain size.',\n",
       "                   'linear_intercepts': False,\n",
       "                   'correction_factor': 1.5,\n",
       "                   'notes': 'Twiss (1977) piezometer was calibrated using the linear intercepts (LI) multiplied\\nby 1.5 (correction factor). Equivalent circular diameters (ECD) without stereological\\ncorrection must be converted to LIs using the empirical equation of De Hoff and\\nRhines (1968) as follows LI = (1.5 / sqrt(4/pi)) * ECD\\n'}},\n",
       "          olivine={'VanderWal_wet': {'year': 1993,\n",
       "                    'reference': 'https://doi.org/10.1029/93GL01382',\n",
       "                    'B': 1355.4,\n",
       "                    'm': 0.75,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': True,\n",
       "                    'correction_factor': 1.5,\n",
       "                    'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'},\n",
       "                   'Jung_Karato': {'year': 2001,\n",
       "                    'reference': 'https://doi.org/10.1016/S0191-8141(01)00005-0',\n",
       "                    'B': 5461.03,\n",
       "                    'm': 0.85,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': True,\n",
       "                    'correction_factor': 1.5,\n",
       "                    'notes': 'The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}},\n",
       "          calcite={'Rutter_SGR': {'year': 1995,\n",
       "                    'reference': 'https://doi.org/10.1029/95JB02500',\n",
       "                    'B': 812.83,\n",
       "                    'm': 0.88,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': False,\n",
       "                    'correction_factor': False,\n",
       "                    'notes': 'Only applies to subgrain rotation recrystallization'},\n",
       "                   'Rutter_GBM': {'year': 1995,\n",
       "                    'reference': 'https://doi.org/10.1029/95JB02500',\n",
       "                    'B': 2691.53,\n",
       "                    'm': 0.89,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': False,\n",
       "                    'correction_factor': False,\n",
       "                    'notes': 'Only applies to grain boundary migration recrystallization'},\n",
       "                   'Barnhoorn': {'year': 2003,\n",
       "                    'reference': 'https://doi.org/10.1016/j.jsg.2003.11.024',\n",
       "                    'B': 537.03,\n",
       "                    'm': 0.82,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': False,\n",
       "                    'correction_factor': False,\n",
       "                    'notes': 'None'},\n",
       "                   'Platt_Bresser': {'year': 2017,\n",
       "                    'reference': 'https://doi.org/10.1016/j.jsg.2017.10.012',\n",
       "                    'B': 538.4,\n",
       "                    'm': 0.82,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS) in linear scale.',\n",
       "                    'linear_intercepts': False,\n",
       "                    'correction_factor': False,\n",
       "                    'notes': 'Contrary to other calcite piezometers, this one was calibrated using the RMS mean\\ninstead of the arithmetic mean.\\n'},\n",
       "                   'Valcke': {'year': 2015,\n",
       "                    'reference': 'https://doi.org/10.1144/SP409.4',\n",
       "                    'B': 1467.92,\n",
       "                    'm': 1.67,\n",
       "                    'warn': 'Please ensure that you have entered the apparent grain size the arithmetic mean in linear scale.',\n",
       "                    'linear_intercepts': False,\n",
       "                    'correction_factor': False,\n",
       "                    'notes': 'None'}},\n",
       "          feldspar={'Post_Tullis_BLG': {'year': 1999,\n",
       "                     'reference': 'https://doi.org/10.1016/S0040-1951(98)00260-1',\n",
       "                     'B': 433.4,\n",
       "                     'm': 1.52,\n",
       "                     'warn': 'Please ensure that you have entered the apparent grain size as the median in linear scale.',\n",
       "                     'linear_intercepts': True,\n",
       "                     'correction_factor': False,\n",
       "                     'notes': 'The Post and Tullis (1999) piezometer was calibrated using the median of the\\nequivalent circular diameters (ECD) grain size with no stereological correction.\\n'}})"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_database"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9d581560-58f7-4de6-9049-6194868e1c4b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'year': 2003,\n",
       " 'reference': 'https://doi.org/10.1029/2003GL018444',\n",
       " 'B': 669.0,\n",
       " 'm': 0.79,\n",
       " 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       " 'linear_intercepts': False,\n",
       " 'correction_factor': False,\n",
       " 'notes': 'Only applies to recrystallization regimes 2 and 3 (SGR, GBM)'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_database.quartz['Stipp_Tullis']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "4b1aaef2-aaca-47a5-9b43-d1bf7aab72f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'VanderWal_wet': {'year': 1993,\n",
       "  'reference': 'https://doi.org/10.1029/93GL01382',\n",
       "  'B': 1355.4,\n",
       "  'm': 0.75,\n",
       "  'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "  'linear_intercepts': True,\n",
       "  'correction_factor': 1.5,\n",
       "  'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'},\n",
       " 'Jung_Karato': {'year': 2001,\n",
       "  'reference': 'https://doi.org/10.1016/S0191-8141(01)00005-0',\n",
       "  'B': 5461.03,\n",
       "  'm': 0.85,\n",
       "  'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "  'linear_intercepts': True,\n",
       "  'correction_factor': 1.5,\n",
       "  'notes': 'The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "database[\"data\"][\"olivine\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f4928e22-bd7b-47b2-9527-3a17a4ee9a6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "namespace(VanderWal_wet={'year': 1993,\n",
       "                         'reference': 'https://doi.org/10.1029/93GL01382',\n",
       "                         'B': 1355.4,\n",
       "                         'm': 0.75,\n",
       "                         'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                         'linear_intercepts': True,\n",
       "                         'correction_factor': 1.5,\n",
       "                         'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'},\n",
       "          Jung_Karato={'year': 2001,\n",
       "                       'reference': 'https://doi.org/10.1016/S0191-8141(01)00005-0',\n",
       "                       'B': 5461.03,\n",
       "                       'm': 0.85,\n",
       "                       'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "                       'linear_intercepts': True,\n",
       "                       'correction_factor': 1.5,\n",
       "                       'notes': 'The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'})"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "olivine = SimpleNamespace(**database[\"data\"][\"olivine\"])\n",
    "olivine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d035886d-3088-46a6-9568-d768dc465072",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'year': 1993,\n",
       " 'reference': 'https://doi.org/10.1029/93GL01382',\n",
       " 'B': 1355.4,\n",
       " 'm': 0.75,\n",
       " 'warn': 'Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       " 'linear_intercepts': True,\n",
       " 'correction_factor': 1.5,\n",
       " 'notes': 'The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "olivine.VanderWal_wet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "839111b7-837d-416d-af87-516fac2bf4a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "year: 1993\n",
      "reference: https://doi.org/10.1029/93GL01382\n",
      "B: 1355.4\n",
      "m: 0.75\n",
      "warn: Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.\n",
      "linear_intercepts: True\n",
      "correction_factor: 1.5\n",
      "notes: The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\n",
      "multiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\n",
      "to LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for feature, data in olivine.VanderWal_wet.items():\n",
    "    print(f\"{feature}: {data}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "7fdf3372-8ddf-4fe2-9df4-6a8cdfb1dea1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "year: 2001\n",
      "reference: https://doi.org/10.1016/S0191-8141(01)00005-0\n",
      "B: 5461.03\n",
      "m: 0.85\n",
      "warn: Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.\n",
      "linear_intercepts: True\n",
      "correction_factor: 1.5\n",
      "notes: The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size\n",
      "multiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\n",
      "to LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for feature, data in olivine.Jung_Karato.items():\n",
    "    print(f\"{feature}: {data}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "67ddbac6-c50a-46f8-9718-429c06c49e4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "namespace(year=1993,\n",
       "          reference='https://doi.org/10.1029/93GL01382',\n",
       "          B=1355.4,\n",
       "          m=0.75,\n",
       "          warn='Please ensure that you have entered the apparent grain size as the arithmetic mean in linear scale.',\n",
       "          linear_intercepts=True,\n",
       "          correction_factor=1.5,\n",
       "          notes='The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\\nmultiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\\nto LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\\n')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "piezo = SimpleNamespace(**olivine.VanderWal_wet)\n",
    "piezo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "64ba7554-8bfa-4fab-a53f-6b12858a917a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Van der Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size\n",
      "multiplied by 1.5 (correction factor). ECDs without stereological correction will be converted\n",
      "to LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(piezo.notes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "d297267b-71fc-4cc5-a530-1ec72652128e",
   "metadata": {},
   "outputs": [],
   "source": [
    "quartz = SimpleNamespace(**database[\"data\"][\"quartz\"])\n",
    "olivine = SimpleNamespace(**database[\"data\"][\"olivine\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "14baea98-5568-4b4d-a10e-97d24c6799e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "test = SimpleNamespace(quartz=quartz, olivine=olivine)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8e584d5e-82e8-4bac-bf3f-d91f57567495",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'year': 2017,\n",
       " 'reference': 'https://doi.org/10.1002/2017GL073836',\n",
       " 'B': 593.0,\n",
       " 'm': 0.71,\n",
       " 'warn': 'Please ensure that you have entered the apparent grain size as the root mean square (RMS).',\n",
       " 'linear_intercepts': False,\n",
       " 'correction_factor': False,\n",
       " 'notes': 'None'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.quartz.Cross"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d183fd8-3192-4ffb-a859-76198332fc30",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
